#include "TDBase.h"

MapBrick::MapBrick()
{
}

MapBrick::MapBrick(
	int type, 
	const vector3di& center,
	int dir, 
	bool towerable,
	bool walkable,
	int nb0,
	int nb1,
	int nb2,
	int nb3
)
:_type(type)
,_center(center)
,_dir(dir)
,_towerable(towerable)
,_walkable(walkable)
{
	assert (type>=0 && type<BRICK_TYPE_COUNT);

	_neighbor[0] = nb0;
	_neighbor[1] = nb1;
	_neighbor[2] = nb2;
	_neighbor[3] = nb3;
}

int MapBrick::DistanceTo (const MapBrick& other) const
{
	return abs(_center.X -other._center.X) +abs(_center.Y -other._center.Y) +abs(_center.Z -other._center.Z);
}

int MapBrick::GetNeighborIdx(int d) const
{
	assert (d>=0 && d<4);

	return _neighbor[d];
}

bool MapBrick::IsWalkable() const
{
	return _walkable;
}

const vector3di& MapBrick::Center() const
{
	return _center;
}

int MapBrick::Type() const 
{ 
	return _type; 
}